import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.lines import Line2D

# 定义身体各部分的坐标
head = (0.5, 0.9)            # 头部中心点
body = [(0.5, 0.7), (0.5, 0.5)]  # 身体中心线
left_arm = [(0.5, 0.7), (0.3, 0.6), (0.2, 0.4)]  # 左臂
right_arm = [(0.5, 0.7), (0.7, 0.6), (0.8, 0.4)]  # 右臂
left_leg = [(0.5, 0.5), (0.4, 0.3), (0.3, 0.1)]   # 左腿
right_leg = [(0.5, 0.5), (0.6, 0.3), (0.7, 0.1)]  # 右腿

# 创建图形
fig, ax = plt.subplots(figsize=(6, 10))
ax.set_aspect('equal')

# 绘制头部
head_circle = patches.Circle(head, 0.05, color='white')
ax.add_patch(head_circle)

# 绘制圆角线条
def draw_rounded_line(segment):
    x_coords, y_coords = zip(*segment)
    line = Line2D(x_coords, y_coords, linewidth=20, color='white',
                  solid_capstyle='round', solid_joinstyle='round')  # 设置圆角
    ax.add_line(line)

draw_rounded_line(body)       # 身体
draw_rounded_line(left_arm)   # 左臂
draw_rounded_line(right_arm)  # 右臂
draw_rounded_line(left_leg)   # 左腿
draw_rounded_line(right_leg)  # 右腿

# 设置坐标轴背景透明
ax.set_facecolor('none')
ax.axis('off')

# 保存图像为透明背景的 PNG
plt.savefig("transparent_pose.png", transparent=True, dpi=100)
plt.show()